﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Commerce/Views/Shared/Backend.Master"
    Inherits="System.Web.Mvc.ViewPage<IShopSetting>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%: "Settings".Localize()%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h3 class="title">
        <%: "Settings".Localize()%></h3>
    <div class="common-form">
        <% using (Html.BeginForm())
           { %>
        <ul class="tabs clearfix">
            <li class="current"><a href="#general">
                <%:"General".Localize() %></a></li>
            <li><a href="#imageSize">
                <%:"Image size".Localize() %></a></li>
        </ul>
        <div id="general" class="tab-content">
            <fieldset>
                <table>
                    <tbody>
                        <tr>
                            <th>
                                <label>
                                    <%:"Price index".Localize() %>
                                </label>
                                <a class="tooltip-link"></a><span class="hide">
                                    <%: "Raise all prices by the specified percentage.".Localize()%></span> </span>
                            </th>
                            <td>
                                <%: Html.TextBoxFor(model => model.PriceIndex, new { @class = "medium" })%>
                                <%: Html.ValidationMessageFor(model => model.PriceIndex) %>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Culture".Localize() %></label>
                                <a class="tooltip-link"></a><span class="hide">
                                    <%: "The culture shown on your website. This is used to display currency, date, number and other culture related content.".Localize()%></span>
                            </th>
                            <td>
                                <%: Html.DropDownList("ThreadCulture",(IEnumerable<SelectListItem>)ViewData["CultureInfos"], new { @class = "medium" })%>
                                <%: Html.ValidationMessageFor(model => model.ThreadCulture)%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Currency ISO code".Localize() %>
                                </label>
                                <a class="tooltip-link"></a><span class="hide">
                                    <%: "Select a currency for the prices of your products.".Localize()%></span>
                            </th>
                            <td>
                                <%: Html.DropDownList("CurrencyISOCode", (IEnumerable<SelectListItem>)ViewData["Currencies"], new { @class = "medium" })%>
                                <%: Html.ValidationMessageFor(m => m.CurrencyISOCode)%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Weight unit".Localize() %>
                                </label>
                            </th>
                            <td>
                                <%: Html.TextBoxFor(model => model.WeightUnit, new { @class = "medium" })%>
                                <%: Html.ValidationMessageFor(model => model.WeightUnit)%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                <%:"Size unit".Localize() %></label>
                                <%: Html.LabelFor(model => model.SizeUnit) %>
                                <!--
                                <a class="tooltip-link"></a><span class="hide">
                                    <%: "SizeUnit_Tooltip".Localize() %></span> -->
                            </th>
                            <td>
                                <%: Html.TextBoxFor(model => model.SizeUnit, new { @class = "medium" })%>
                                <%: Html.ValidationMessageFor(model => model.SizeUnit)%>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            <label>
                                <%:"Default delivery days".Localize()%>
                            </label>
                                
                                <!--
                                <a class="tooltip-link"></a><span class="hide">
                                    <%: "DefaultDeliveryDays_Tooltip".Localize() %>
                                </span>
                                -->
                            </td>
                            <td>
                                <%: Html.TextBoxFor(i => i.DefaultDeliveryDays, new { @class = "medium" })%>
                                <%: Html.ValidationMessageFor(i=>i.DefaultDeliveryDays) %>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <%: Html.HiddenFor(model=> model.Id) %>
            </fieldset>
        </div>
        <div id="imageSize" class="tab-content hide">
            <fieldset>
                <table id="custom-size-container">
                    <tr>
                        <th>
                            <label>
                                <%:"Thumbnail".Localize() %>
                            </label>
                        </th>
                        <td>
                            <%= Html.Build<HtmlTextbox>()
                                    .SetName("ImageSettings.Thumbnail.Height")
                            .SetValue(this.Model.ImageSettings.Thumbnail.Height.ToString())
                            .SetAttribute("style","width:90px") %>
                            <span style="margin-right: 4px; line-height: 20px;" class="left">X</span>
                            <%= Html.Build<HtmlTextbox>()
                                    .SetName("ImageSettings.Thumbnail.Width")
                                    .SetValue(this.Model.ImageSettings.Thumbnail.Width.ToString())
                            .SetAttribute("style","width:90px") %>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <label>
                                <%:"Detail".Localize() %></label>
                        </th>
                        <td>
                            <%= Html.Build<HtmlTextbox>()
                                                                     .SetName("ImageSettings.Detail.Height")
                                                             .SetValue(this.Model.ImageSettings.Detail.Height.ToString())
                                                             .SetAttribute("style", "width:90px")%>
                            <span style="margin-right: 4px; line-height: 20px;" class="left">X</span>
                            <%= Html.Build<HtmlTextbox>()
                                                                .SetName("ImageSettings.Detail.Width")
                                                                .SetValue(this.Model.ImageSettings.Detail.Width.ToString())
                                                        .SetAttribute("style", "width:90px")%>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <label>
                                <%:"List".Localize() %></label>
                        </th>
                        <td>
                            <%= Html.Build<HtmlTextbox>().SetName("ImageSettings.List.Height")
                                                           .SetValue(this.Model.ImageSettings.List.Height.ToString())
                                                           .SetAttribute("style", "width:90px")%>
                            <span style="margin-right: 4px; line-height: 20px;" class="left">X</span>
                            <%= Html.Build<HtmlTextbox>().SetName("ImageSettings.List.Width")
                                                             .SetValue(this.Model.ImageSettings.List.Width.ToString())
                                                     .SetAttribute("style", "width:90px")%>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <label>
                                <%:"Cart".Localize() %></label>
                        </th>
                        <td>
                            <%= Html.Build<HtmlTextbox>()
                                    .SetName("ImageSettings.Cart.Height")
                            .SetValue(this.Model.ImageSettings.Cart.Height.ToString())
                            .SetAttribute("style","width:90px") %>
                            <span style="margin-right: 4px; line-height: 20px;" class="left">X</span>
                            <%= Html.Build<HtmlTextbox>()
                                    .SetName("ImageSettings.Cart.Width")
                                    .SetValue(this.Model.ImageSettings.Cart.Width.ToString())
                            .SetAttribute("style","width:90px") %>
                        </td>
                    </tr>
                    <% 
               var len = 0;
               foreach (var item in this.Model.ImageSettings.CustomSizes)
               {
                   var prefix = "ImageSettings.CustomSizes[" + len.ToString() + "]";
               
                    %>
                    <tr>
                        <th>
                            <%= Html.Build<HtmlTextbox>().SetName(prefix + ".Name").AddClass("short").SetValue(item.Name)  %>
                        </th>
                        <td>
                            <%= Html.Build<HtmlHidden>().SetValue(len.ToString()).SetName("ImageSettings.CustomSizes.index")%>
                            <%= Html.Build<HtmlTextbox>().SetName(prefix + ".Height").SetAttribute("style","width: 90px;").SetValue(item.Height.ToString()) %>
                            <span style="margin-right: 4px; line-height: 20px;" class="left">X</span>
                            <%= Html.Build<HtmlTextbox>().SetName(prefix + ".Width").SetAttribute("style", "width: 90px;").SetValue(item.Width.ToString())%>
                            <a href="#" class="o-icon remove form-action remove-custom-size" title="Remove">Remove</a>
                        </td>
                    </tr>
                    <%
                   len++;
               }%>
                </table>
                <a class="o-icon add add-custom-field" href="#" title="Add">
                    <%:"Add".Localize() %></a>
            </fieldset>
        </div>
        <p class="buttons">
            <input type="submit" class="button" name="save" value="<%: "Save".Localize() %>" /></p>
        <script type="text/javascript">
        var len = <%= len %>;       
        </script>
        <%} %>
    </div>
    <script type="text/javascript">
        var successMessage = '<%= "The settings have been updated.".Localize()%>';
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <%using (var loader = ClientLoader.RegisterInstance())
      {
          loader.Run(ViewData["settings_validators"] as string);
          loader.Run(ViewData["imagesize_validators"] as string);
          loader.Require("settings.index.js");
      } %>
</asp:Content>
